package com.kehao.leetcode.basic.string;

import java.util.ArrayList;

public class StringSolution5 {
    public boolean isPalindrome(String s) {
        char[] charArray = s.toLowerCase().toCharArray();
        ArrayList<Character> list = new ArrayList<>();
        for (int i = 0; i < charArray.length; i++) {
            if(charArray[i]<='z'&&charArray[i]>='a'){
                list.add(charArray[i]);
            }else if(charArray[i]<='9'&&charArray[i]>='0'){
                list.add(charArray[i]);
            }
        }
        for (int i = 0; i < list.size()/2; i++) {
            if(list.get(i)!=list.get(list.size()-i-1)){
                return false;
            }
        }
        return true;
    }
}
